<?php

/**
 * class Standart_Helper_LocalDatepicker
 *
 * This view helper renders datepicker, localized if needed.
 *
 * Usage example:
 * <label for="startDate">Travel Start Date:</label>
 * <?php
 *     echo $this->localDatepicker("startDate", '', array(
 *         'defaultDate' => '+7',
 *         'minDate'     => '+7',
 *         'autoSize'    => false,
 *     ));
 * ?>
 */
class Standart_Helper_LocalDatepicker extends Zend_View_Helper_Abstract
{
    public function localDatepicker($id, $value, $params = array(), $attribs = array())
    {

        $jq     = ZendX_JQuery_View_Helper_JQuery::getJQueryHandler();
        $locale = new Zend_Locale; 
        if ($locale->getLanguage() !== 'en')
        { 
            $jqLang = $locale->getLanguage();
            $this->view->JQuery()->addJavascriptFile('http://jquery-ui.googlecode.com/svn/tags/latest/ui/minified/i18n/jquery-ui-i18n.min.js');
            $this->view->JQuery()->addOnLoad('$.datepicker.setDefaults($.extend({showMonthAfterYear: false}, $.datepicker.regional[\''. $jqLang .'\']));');
        }
        $params['dateFormat'] = 'yy-mm-dd';

        return $this->view->datePicker($id, $value, $params, $attribs);
    }
}